package calbs.socket.analysis;

import calbs.socket.pojo.req.ReqData;
import calbs.socket.pojo.req.ReqGetAbLineMsg;
import calbs.socket.tool.CHexConver;
import calbs.socket.tool.LatLngTool;

/**
 * Created by Q on 2017/8/3.
 */
public class GetAbLineAnalysisImp implements AnalysisI<ReqGetAbLineMsg> {
    @Override
    public ReqData<ReqGetAbLineMsg> analysisMsg(ReqData<ReqGetAbLineMsg> reqData){
        ReqGetAbLineMsg reqGetAbLineMsg = reqData.getBody();
        String content = reqGetAbLineMsg.getContent();
        Integer longitude = Integer.parseInt(content.substring(0,2*4),16);
        reqGetAbLineMsg.setLongitude(LatLngTool.getLatLngByOld(longitude));
        content = content.substring(2*4);
        Integer latitude = Integer.parseInt(content.substring(0,2*4),16);
        reqGetAbLineMsg.setLatitude(LatLngTool.getLatLngByOld(latitude));
        content = content.substring(2*4);
        Integer height = Integer.parseInt(content.substring(0,2*4),16);
        reqGetAbLineMsg.setHeight(LatLngTool.getLatLngByOld(height));
        content = content.substring(2*4);
        Integer textLength = Integer.parseInt(content.substring(0,2*2),16);
        content = content.substring(2*2);
        String fieldName = CHexConver.hexStr2Str(content);
        reqGetAbLineMsg.setFieldName(fieldName);
        return reqData;
    }
}
